/**
 * 
 */
package com.youth.fund.hk.hostManager.manager.dao.mybatis;

import java.sql.Timestamp;
import java.util.List;

import org.springframework.stereotype.Repository;

import com.youth.fund.hk.hostManager.common.Constants;
import com.youth.fund.hk.hostManager.common.dao.mybatis.BaseMybatisDao;
import com.youth.fund.hk.hostManager.manager.dao.TypeDao;
import com.youth.fund.hk.hostManager.manager.datamodel.TypeModel;

/**
 * @author Sunk_Sky
 *
 * 2014年11月19日下午2:57:13
 */
@Repository("TypeDao")
public class TypeMybatisDaoImpl extends BaseMybatisDao<TypeModel, Integer>
		implements TypeDao
{
	
	private final static String CREATE_ZH_CN = "type_zh_cn.create";

	private final static String DELETE_ZH_CN = "type_zh_cn.delete";

	private final static String UPDATE_ZH_CN = "type_zh_cn.update";

	private final static String QUERY_BY_CONDITION_ZH_CN = "type_zh_cn.list_by_condition";
	
	private final static String CREATE_ZH_HK = "type_zh_hk.create";

	private final static String DELETE_ZH_HK = "type_zh_hk.delete";

	private final static String UPDATE_ZH_HK = "type_zh_hk.update";

	private final static String QUERY_BY_CONDITION_ZH_HK = "type_zh_hk.list_by_condition";
	
	private final static String CREATE_EN = "type_en.create";

	private final static String DELETE_EN = "type_en.delete";

	private final static String UPDATE_EN = "type_en.update";

	private final static String QUERY_BY_CONDITION_EN = "type_en.list_by_condition";

	
	
	/* (non-Javadoc)
	 * @see com.youth.fund.hk.hostManager.common.dao.ICommonDao#create(java.io.Serializable)
	 */
	@Override
	public boolean create(TypeModel model)
	{
		Timestamp timestamp = new Timestamp(System.currentTimeMillis());

		model.setSetup_time(timestamp);

		model.setUpdate_time(timestamp);
		
		if(Constants.LANG_EN.equalsIgnoreCase(model.getLang()))
		{
			return super.create(model, CREATE_EN);
		}else if(Constants.LANG_ZH_CN.equalsIgnoreCase(model.getLang()))
		{
			return super.create(model, CREATE_ZH_CN);
		}else
		{
			return super.create(model, CREATE_ZH_HK);
		}
	}

	/* (non-Javadoc)
	 * @see com.youth.fund.hk.hostManager.common.dao.ICommonDao#delete(java.io.Serializable)
	 */
	@Override
	public boolean delete(TypeModel model)
	{
		if(Constants.LANG_EN.equalsIgnoreCase(model.getLang()))
		{
			return super.delete(model, DELETE_EN);
		}else if(Constants.LANG_ZH_CN.equalsIgnoreCase(model.getLang()))
		{
			return super.delete(model, DELETE_ZH_CN);
		}else
		{
			return super.delete(model, DELETE_ZH_HK);
		}
	}

	/* (non-Javadoc)
	 * @see com.youth.fund.hk.hostManager.common.dao.ICommonDao#update(java.io.Serializable)
	 */
	@Override
	public boolean update(TypeModel model)
	{
		Timestamp timestamp = new Timestamp(System.currentTimeMillis());

		model.setUpdate_time(timestamp);
		
		if(Constants.LANG_EN.equalsIgnoreCase(model.getLang()))
		{
			return super.update(model, UPDATE_EN);
		}else if(Constants.LANG_ZH_CN.equalsIgnoreCase(model.getLang()))
		{
			return super.update(model, UPDATE_ZH_CN);
		}else
		{
			return super.update(model, UPDATE_ZH_HK);
		}
	}

	/* (non-Javadoc)
	 * @see com.youth.fund.hk.hostManager.common.dao.ICommonDao#query(java.io.Serializable)
	 */
	@Override
	public List<TypeModel> query(TypeModel model)
	{
		if(Constants.LANG_EN.equalsIgnoreCase(model.getLang()))
		{
			return super.query(model, QUERY_BY_CONDITION_EN);
		}else if(Constants.LANG_ZH_CN.equalsIgnoreCase(model.getLang()))
		{
			return super.query(model, QUERY_BY_CONDITION_ZH_CN);
		}else
		{
			return super.query(model, QUERY_BY_CONDITION_ZH_HK);
		}
	}

	/* (non-Javadoc)
	 * @see com.youth.fund.hk.hostManager.common.dao.ICommonDao#queryOne(java.io.Serializable)
	 */
	@Override
	public TypeModel queryOne(TypeModel model)
	{
		if(Constants.LANG_EN.equalsIgnoreCase(model.getLang()))
		{
			return super.queryOne(model, QUERY_BY_CONDITION_EN);
		}else if(Constants.LANG_ZH_CN.equalsIgnoreCase(model.getLang()))
		{
			return super.queryOne(model, QUERY_BY_CONDITION_ZH_CN);
		}else
		{
			return super.queryOne(model, QUERY_BY_CONDITION_ZH_HK);
		}
	}

}
